<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表格-列表</title>
<link href="<%=path %>/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=path %>/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/common.js"></script> 
<script type="text/javascript">
/*
 *_contextPath:上下文路径
 *_modulePath: 模块路径
 */
var  _contextPath="<%=path%>";
var  _modulePath=_contextPath+"/sys/";
$(document).ready(function(){
  $(".clicks").click(function(){
   _open(_modulePath+"textures_open.action?view=add");
  });
});
</script>
<script type="text/javascript">
	//删除
	$(document).ready(function(){
			var id;
			var url;
			//隐藏
			
			$("#academyList1").hide();
			$("#academyList2").hide();
			$("#SerMajor1").hide();
			$("#SerMajor2").hide();
			$("#SerCalss1").hide();
			$("#SerCalss2").hide();
			$("#sysUserList1").hide();
			$("#sysUserList2").hide();
			$("#SerStusdio1").hide();
			$("#SerStusdio2").hide();
			$("#son").hide();
			$("#sonId").hide();
  			$(".tablelinkdelete").click(function(){
  			id = $(this).attr("idValue");
 			/* carId = $(this).attr("userId"); */
 			url =" <%= basePath%>/biz/ServiceClass_delete.action?id="+id;
 			 $(".tip").fadeIn(200);
 			 });
  
 			 $(".tiptop a").click(function(){
 			 $(".tip").fadeOut(200);
			});

  			$(".sure").click(function(){
  			$(".tip").fadeOut(100);
  					window.location.href=url;
			});

				  $(".cancel").click(function(){
				  $(".tip").fadeOut(100);
				});
		
	});
	
	
	
	
	$(function(){	
     $("#branchType").change(function(){ 
         var branchType = $("#branchType").val();
         
         if(branchType==2){
         
        $.ajax({
          timeout: 3000,
          async: false,
          type: "post",
          url: "<%=path%>/biz/ServiceBranch_listtoJson.action",
          dataType:"json",
          data: {
           'b.branchType': branchType
        },
        success: function (data2) {
            
            $("#academyList1").show();
			$("#academyList2").show();
			$("#SerMajor1").show();
			$("#SerMajor2").show();
			$("#SerCalss1").hide();
			$("#SerCalss2").hide();
			$("#sysUserList1").hide();
			$("#sysUserList2").hide();
			$("#SerStusdio1").hide();
			$("#SerStusdio2").hide();
        
        $("#son").insertAfter("#SerMajor1");
          $("#sonId").insertAfter("#son");
        
          $("#sonId").find("option").remove();
          // $("#userClass").find("option").remove();
          $("#sonId").append("<option value=''>-------------请选择专业-------------</option>");
          //$("#userClass").append("<option value=''>-------------请选择班级--------</option>");
          $(data2).each(function (key) {
          
          
          var opt = $("<option></option>").text(data2[key].majorName).val(data2[key].majorId);
                         
                         $("#sonId").append(opt);
                        
       });
   
    }
        });
        }else if(branchType==0){
         $.ajax({
          timeout: 3000,
          async: false,
          type: "post",
          url: "<%=path%>/biz/ServiceBranch_listtoJson.action",
          dataType:"json",
          data: {
           'b.branchType': branchType
        },
        success: function (data0) {
        
          $("#academyList1").show();
			$("#academyList2").show();
			$("#SerMajor1").show();
			$("#SerMajor2").show();
			$("#SerCalss1").show();
			$("#SerCalss2").show();
			$("#sysUserList1").show();
			$("#sysUserList2").show();
			$("#SerStusdio1").hide();
			$("#SerStusdio2").hide();
          $("#son").insertAfter("#sysUserList2");
          $("#sonId").insertAfter("#son");
          $("#sonId").find("option").remove();
          // $("#userClass").find("option").remove();
          $("#sonId").append("<option value=''>-------------请选择个人-------------</option>");
          //$("#userClass").append("<option value=''>-------------请选择班级--------</option>");
          $(data0).each(function (key) {
          
          
          var opt = $("<option></option>").text(data0[key].userName).val(data0[key].userId);
                         
                         $("#sonId").append(opt);
                        
       });
   
    }
        });
        }else if(branchType==1){
            $.ajax({
          timeout: 3000,
          async: false,
          type: "post",
          url: "<%=path%>/biz/ServiceBranch_listtoJson.action",
          dataType:"json",
          data: {
           'b.branchType': branchType
        },
        success: function (data1) {
        
           $("#academyList1").show();
			$("#academyList2").show();
			$("#SerMajor1").show();
			$("#SerMajor2").show();
			$("#SerCalss1").show();
			$("#SerCalss2").show();
			$("#sysUserList1").hide();
			$("#sysUserList2").hide();
			$("#SerStusdio1").hide();
			$("#SerStusdio2").hide();
          $("#son").insertAfter("#SerCalss1");
          $("#sonId").insertAfter("#son");
          
          $("#sonId").find("option").remove();
          // $("#userClass").find("option").remove();
          $("#sonId").append("<option value=''>-------------请选择班级-------------</option>");
          //$("#userClass").append("<option value=''>-------------请选择班级--------</option>");
          $(data1).each(function (key) {
          
          
          var opt = $("<option></option>").text(data1[key].className).val(data1[key].classId);
                         
                         $("#sonId").append(opt);
                        
       });
   
    }
        });
        }else if(branchType==3){
         $.ajax({
          timeout: 3000,
          async: false,
          type: "post",
          url: "<%=path%>/biz/ServiceBranch_listtoJson.action",
          dataType:"json",
          data: {
           'b.branchType': branchType
        },
        success: function (data3) {
          
            $("#academyList1").show();
			$("#academyList2").show();
			$("#SerMajor1").hide();
			$("#SerMajor2").hide();
			$("#SerCalss1").hide();
			$("#SerCalss2").hide();
			$("#sysUserList1").hide();
			$("#sysUserList2").hide();
			$("#SerStusdio1").hide();
			$("#SerStusdio2").hide();
			
		  $("#son").insertAfter("#academyList2");
          $("#sonId").insertAfter("#son");
           
          $("#sonId").find("option").remove();
          // $("#userClass").find("option").remove();
          $("#sonId").append("<option value=''>-------------请选择学院-------------</option>");
          //$("#userClass").append("<option value=''>-------------请选择班级--------</option>");
          $(data3).each(function (key) {
          
          
          var opt = $("<option></option>").text(data3[key].academyName).val(data3[key].academyId);
                         
                         $("#sonId").append(opt);
                        
       });
   
    }
        });
        }else if(branchType==4){
         $.ajax({
          timeout: 3000,
          async: false,
          type: "post",
          url: "<%=path%>/biz/ServiceBranch_listtoJson.action",
          dataType:"json",
          data: {
           'b.branchType': branchType
        },
        success: function (data4) {
        
          $("#academyList1").hide();
			$("#academyList2").hide();
			$("#SerMajor1").hide();
			$("#SerMajor2").hide();
			$("#SerCalss1").hide();
			$("#SerCalss2").hide();
			$("#sysUserList1").hide();
			$("#sysUserList2").hide();
			$("#SerStusdio1").show();
			$("#SerStusdio2").show();
			$("#son").insertAfter("#academyList2");
          $("#sonId").insertAfter("#son");
        
          $("#sonId").find("option").remove();
          // $("#userClass").find("option").remove();
          $("#sonId").append("<option value=''>-------------请选择科室-------------</option>");
          //$("#userClass").append("<option value=''>-------------请选择班级--------</option>");
          $(data4).each(function (key) {
          
          
          var opt = $("<option></option>").text(data4[key].studioName).val(data4[key].studioId);
                         
                         $("#sonId").append(opt);
                        
       });
         
    }
        });
        }
        
        }) 
     });
     
     $(function(){
     
    $("#academyList2").change(function(){     
        $.ajax({
          timeout: 3000,
          async: false,
          type: "post",
          url: "<%=path%>/biz/ServiceBranch_majortoJson.action",
          dataType:"json",
          data: {
           sonId: $("#academyList2").val()
        },
        success: function (data5) {
          $("#SerMajor2").find("option").remove();
           
          $("#SerMajor2").append("<option value=''>-------------请选择专业--------</option>");
          
          $(data5).each(function (key) {
          
          
          var opt = $("<option></option>").text(data5[key].majorName).val(data5[key].majorId);
                         
                         $("#SerMajor2").append(opt);
                        
       });
   
    }
        }); 
     });
     
     
     $("#SerMajor2").change(function(){
         $.ajax({
            timeout:3000,
            async:false,
            type:"post",
            url:"<%=path%>/biz/ServiceBranch_classtoJson.action",
            dataType:"json",
            data:{
              sonId:$("#SerMajor2").val()
            },
           success:function(data6){
              $("#SerCalss2").find("option").remove();
              $("#SerCalss2").append("<option>-----请选择班级------</option>");
              $(data6).each(function(key){
                 
                var opt = $("<option></option>").text(data6[key].className).val(data6[key].classId)
                $("#SerCalss2").append(opt);
              });
              
           }
         
         });
     });
     
     
     
     $("#SerCalss2").change(function(){
        $.ajax({
           timeout:3000,
           anysc:false,
           type:"post",
           url:"<%=path%>/biz/ServiceBranch_usertoJson.action",
           dataType:"json",
           data:{
             sonKey:$("#SerCalss2 option:selected").text()
           },
          success:function(data7){
            $("#sysUserList2").find("option").remove();
            $("#sysUserList2").append("<option>------请选择学生------</option>");
           $(data7).each(function(key){
             var opt = $("<option></option>").text(data7[key].userName).val(data7[key].userId)  
              $("#sysUserList2").append(opt);
           });
          }
        
        });
     
     
     });
     
     
     
     
     })
     
</script>
   <%-- $(function(){
      $("#branchType").change(function(){
	        $.ajax({
	          timeout: 3000,
	          async: false,
	          type: "post",
	          contentType:'application/json;utf-8',
	          url: "<%=path%>/front/ServiceBranchAction_listtoJson.action",
	          dataType:"json",
	          data: {
	           branchType: $("#branchType").val()
	        },
	        success: function (data) {
	          $("#userMajor").empty(); 
	          $(data).each(function (key) {
		          var opt = $("<option></option>").text(data[key].majorName).val(data[key].majorId);
		                         $("#userMajor").append(opt);
		       });
		   
		    }
        }); 
       });
   }); </script>--%>

<style type="text/css">
.verification{
     color:#FF0000;
     fornt-size:20px;
}
.err{
     color:#FF0000;
     fornt-size:13px;
}
</style>
<script type="text/javascript">
/************************************表单检验开始***************************/
<%-- $(document).ready(function(){	
	 
	  $("#userCollege").each(function(){	 	
         $(this).after("<font  class='verification' id='f7'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 
	  $("#userMajor").each(function(){	 	
         $(this).after("<font  class='verification' id='f8'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 
	 $("#userClass").each(function(){	 	
         $(this).after("<font  class='verification' id='f9'>&nbsp;&nbsp;*&nbsp;&nbsp;</font>");      
	 }); 
	 	 	 	 	 	 
	 
	  $("#userCollege").blur(function(){	 	 
		 $("#f7").remove(); 
		 $("#f17").remove();	 
			 if(this.value =="")
			 {
			    $(this).after("<font class='err' id = 'f17'>&nbsp;&nbsp;<img id = 'f7' width='23px' src='<%=path%>/images/err.png'/>学生所在学院必选！</font>");
			 }
			 else{
			    $(this).after("&nbsp;&nbsp;<img id = 'f7' width='23px' src='<%=path%>/images/right.png'/>");
			 }	 	 
	 });
	  $("#userMajor").blur(function(){	 	 
		 $("#f8").remove(); 
		 $("#f18").remove(); 	 
			 if(this.value =="")
			 {
			    $(this).after("<font  class='err' id = 'f18'>&nbsp;&nbsp;<img id = 'f8' width='23px' src='<%=path%>/images/err.png'/>学生所选专业必选！</font>");
			 }
			 else{
			    $(this).after("&nbsp;&nbsp;<img id = 'f8' width='23px' src='<%=path%>/images/right.png'/>");
			 }	 	 
	 });
	  $("#userClass").blur(function(){	 	 
		 $("#f9").remove();	
		 $("#f19").remove(); 
			 if(this.value =="")
			 {
			    $(this).after("<font  class='err' id = 'f19'>&nbsp;&nbsp;<img id = 'f9' width='23px' src='<%=path%>/images/err.png'/>学生所在班级必选！</font>");
			 }
			 else{
			    $(this).after("&nbsp;&nbsp;<img id = 'f9' width='23px' src='<%=path%>/images/right.png'/>");
			 }	 	 
	 });
	 	 
	});
	
	function btn(){
		
		$("#userCollege").trigger("blur");
		$("#userMajor").trigger("blur");
		$("#userClass").trigger("blur");
		var flag = $("#f11").length+$("#f12").length+$("#f13").length+$("#f14").length+$("#f15").length+$("#f16").length+$("#f17").length+$("#f18").length+$("#f19").length;
		console.log("flag---"+flag);
		if(flag == 0){
		  $("#addStu").submit();
		  alert("添加成功");
	   }else{
	   
	   }
	
	}; --%>
</script>
</head>

<body>

	<div class="place">
		<span>位置：</span>
		<ul class="placeul"> 
		     <li><a href="#">首页</a></li>
			<li><a href="#">联系人管理</a></li>
			<li><a href="#">新增联系人</a></li>
		</ul>
	</div>

	<div class="formbody" id="tab1">

		<div class="formtitle">
			<span>新增联系人信息</span>
		</div>

		<form   method="post" id="addStu">
			
			<div  id="Academy">
			<li><label>类 &nbsp;别</label>  
				 <select name="branchType"  id ="branchType" class="dfselect">
				   <option value="">----------请选择类别---------</option>
					    
					   <option value=3  >----------院系----------</option>
					   <option value=2  >----------专业----------</option>
					   <option value=1  >----------班级----------</option>
					   <option value=0  >----------个人----------</option>
					   <option value=4  >----------教师----------</option>
				    </select>
			    </div>
			<li>
				
				<br>
				<!-- 科室-->
				<label id="SerStusdio1">科&nbsp;室</label>
				<select name="SerStusdio"  id ="SerStusdio2" class="dfselect" >
				   <option value="">------------请选择科室------</option>
				   <s:iterator value="SerStusdio">
			        
			        <option id="SerStusdio3" value="${studioId }">${studioName }</option>
			        </s:iterator>
				</select>
				 
				<br><!-- 学院 -->
				<label id="academyList1">学&nbsp;院</label><select name="academyList1"  id ="academyList2" class="dfselect" >
				   <option value="">------------请选择学院------</option>
				   <s:iterator value="academyList1">
			        
			        <option id="academyList3" value="${academyId }">${academyName }</option>
			        </s:iterator>
				</select>
				
				<br><!-- 专业 -->
				<label id="SerMajor1">专&nbsp;业</label><select name="SerMajor"  id ="SerMajor2" class="dfselect" >
				   <option value="">------------请选择专业------</option>
				   <s:iterator value="SerMajor">
			        
			        <option id="SerMajor3" value="${majorId }">${majorName }</option>
			        </s:iterator>
				</select>
				
				<br id="banji"><!-- 班级-->
				<label id="SerCalss1">班&nbsp;级</label><select name="SerCalss"  id ="SerCalss2" class="dfselect" >
				   <option value="">------------请选择班级------</option>
				   <s:iterator value="SerCalss">
			        
			        <option id="SerCalss3" value="${classId }">${className }</option>
			        </s:iterator>
				</select>
				
				<br><!-- 个人-->
				<label id="sysUserList1">个&nbsp;人</label>
				<select name="sysUserList"  id ="sysUserList2" class="dfselect" >
				   <option value="">------------请选择个人------</option>
				   <s:iterator value="sysUserList">
			        
			        <option id="sysUserList3" value="${userId }">${userName }</option>
			        </s:iterator>
				</select>
				
				<br><label id="son">请选择</label>
				<select name="sonId"  id ="sonId" class="dfselect" >
				  <option value="">------------请选择---------</option>
				</select>
				<li>
			   </ul>
				<br/>
				<ul class="forminfo"> <li><label>&nbsp;</label><input name="" type="button" id="save"  class="btn" onclick="add()" value="确认保存" ></li>
				</ul>
		  </form>
				</div>
				<script>
			
				  
				  function add(){
				      var branchType=$("#branchType").val();
				      var inde =$("#sonId option:selected");
				      
				       
			           var academy= $("#academyList2").val();
			           var academytext = $("#academyList2 option:selected").text();
			           
			            var sermajor=$("#SerMajor2").val();
			            var sermajortext = $("#SerMajor2 option:selected").text();
			            
			            
			            var serclass= $("#SerCalss2").val();
			            var serclasstext = $("#SerCalss2 option:selected").text();
			            
			            
			           var sysuser= $("#sysUserList2").val();
			           var sysusertext = $("#sysUserList2 option:selected").text();
			           
			          
			           var serstusdio= $("#SerStusdio2").val();
				       var serstusdiotext = $("#SerStusdio2 option:selected").text();
				    if(branchType==0&&sysuser!=""&&sysusertext!=""){
				    $.ajax({
				       timeout:3000,   
                 url:"<%=path%>/biz/ServiceBranch_add.action",
                 cache : false,
                type:"post",
                data:{'serviceBranch.branchType':$("#branchType").val(),
                'serviceBranch.sonId':sysuser,
                'serviceBranch.sonKey':sysusertext
                     },
				   success:function(){
				     window.location.href="<%=path%>/biz/ServiceBranch_openList.action";
				   }
				    })
				    
				    }else if(branchType==1&&serclass!=""&&serclasstext!=""){
                       $.ajax({
				       timeout:3000,   
                 url:"<%=path%>/biz/ServiceBranch_add.action",
                 cache : false,
                type:"post",
                data:{'serviceBranch.branchType':$("#branchType").val(),
                'serviceBranch.sonId':serclass,
                'serviceBranch.sonKey':serclasstext
                     },
				   success:function(){
				     window.location.href="<%=path%>/biz/ServiceBranch_openList.action";
				   }
				    })
                       
                       }else if(branchType==2&&sermajor!=""&&sermajortext!=""){
                         
                              $.ajax({
				       timeout:3000,   
                 url:"<%=path%>/biz/ServiceBranch_add.action",
                 cache : false,
                type:"post",
                data:{'serviceBranch.branchType':$("#branchType").val(),
                'serviceBranch.sonId':sermajor,
                'serviceBranch.sonKey':sermajortext
                     },
				   success:function(){
				     window.location.href="<%=path%>/biz/ServiceBranch_openList.action";
				   }
				    }) 
                       
                       
                       }else if(branchType==3&&academy!=""&&academytext!=""){
                        $.ajax({
                          timeout:3000,
                          url:"<%=path%>/biz/ServiceBranch_add.action",
                          cache : false,
                          type:"post",
                           data:{'serviceBranch.branchType':$("#branchType").val(),
                           'serviceBranch.sonId':academy,
                           'serviceBranch.sonKey':academytext
                             
                          },
                          success:function(){
                            window.location.href="<%=path%>/biz/ServiceBranch_openList.action";
                          }
                        
                        }) 
                        
                       
                       }else if(branchType==4&&serstusdio!=""&&serstusdiotext!=""){
                        $.ajax({
                           timeout:3000,
                           url:"<%=path%>/biz/ServiceBranch_add.action",
                           cache :false,
                           type:"post",
                           data:{'serviceBranch.branchType':$("#branchType").val(),
                           'serviceBranch.sonId':serstusdio,
                           'serviceBranch.sonKey':serstusdiotext
                           },
                           success:function(){
                             window.location.href="<%=path%>/biz/ServiceBranch_openList.action";
                             
                           }
                        
                        })
                         
                       }else{alert("请选择");}
				    
				    
				 
                                   
           
        
                    
				    
				    
				  }
	     
	
				
				</script>
				
				
</body>
</html>
